<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>pthread_cleanup_push</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_007_1216">&nbsp;</a>NAME</h4><blockquote>
pthread_cleanup_push, pthread_cleanup_pop - establish cancellation handlers
</blockquote><h4><a name = "tag_000_007_1217">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="pthread.h.html">pthread.h</a>&gt;

void pthread_cleanup_push(void (*<i>routine</i>)(void*), void *<i>arg</i>);
void pthread_cleanup_pop(int <i>execute</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_007_1218">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>pthread_cleanup_push()</i>
function pushes the specified cancellation cleanup handler
<i>routine</i>
onto the calling thread's cancellation cleanup stack.
The cancellation cleanup handler is popped from the
cancellation cleanup stack and invoked with the argument
<i>arg</i>
when: (a) the thread exits (that is, calls
<i><a href="pthread_exit.html">pthread_exit()</a></i>),
(b) the thread acts upon a cancellation request, or
(c) the thread calls
<i>pthread_cleanup_pop()</i>
with a non-zero
<i>execute</i>
argument.
<p>
The
<i>pthread_cleanup_pop()</i>
function removes the routine at the top of the calling thread's
cancellation cleanup stack and optionally invokes it (if
<i>execute</i>
is non-zero).
<p>
These functions may be implemented as macros and will
appear as statements and in pairs within the same lexical scope (that is, the
<i>pthread_cleanup_push()</i>
macro may be thought to expand to a token list whose first
token is
<b>`{'</b>
with
<i>pthread_cleanup_pop()</i>
expanding to a token list whose last token is the corresponding
<b>`}'</b>.
<p>
The effect of calling
<i><a href="longjmp.html">longjmp()</a></i>
or
<i><a href="siglongjmp.html">siglongjmp()</a></i>
is undefined if there have been any calls to
<i>pthread_cleanup_push()</i>
or
<i>pthread_cleanup_pop()</i>
made without the matching call
since the jump buffer was filled.
The effect of calling
<i><a href="longjmp.html">longjmp()</a></i>
or
<i><a href="siglongjmp.html">siglongjmp()</a></i>
from inside a cancellation cleanup handler is also
undefined unless the jump buffer was also filled in the
cancellation cleanup handler.
</blockquote><h4><a name = "tag_000_007_1219">&nbsp;</a>RETURN VALUE</h4><blockquote>
The
<i>pthread_cleanup_push()</i>
and
<i>pthread_cleanup_pop()</i>
functions return no value.
</blockquote><h4><a name = "tag_000_007_1220">&nbsp;</a>ERRORS</h4><blockquote>
No errors are defined.
<p>
These functions will not return an error code of [EINTR].
</blockquote><h4><a name = "tag_000_007_1221">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_1222">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_1223">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_1224">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="pthread_cancel.html">pthread_cancel()</a></i>,
<i><a href="pthread_setcancelstate.html">pthread_setcancelstate()</a></i>,
<i><a href="pthread.h.html">&lt;pthread.h&gt;</a></i>.
</blockquote><h4>DERIVATION</h4><blockquote>
Derived from the POSIX Threads Extension (1003.1c-1995)
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>

